class MyClass:
    def __init__(self):
        pass

    @classmethod
    def generate_dynamic_method(cls, method_name, param1_name, param2_name):
        def dynamic_method(self, **kwargs):
            param1 = kwargs.get(param1_name)
            param2 = kwargs.get(param2_name)
            return f"Received {param1_name}: {param1}, {param2_name}: {param2}"

        setattr(cls, method_name, dynamic_method)


if __name__ == "__main__":
    # 动态生成一个名为 new_method 的成员函数，其参数名为 arg1 和 arg2
    MyClass.generate_dynamic_method("new_method", "arg1", "arg2")

    # 创建类的实例
    obj = MyClass()

    # 调用动态生成的成员函数
    result = obj.new_method(arg1="value1", arg2="value2")
    print(result)
